package com.zz.hhbl.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.zz.hhbl.event.VersionUpdateEvent
import com.zz.hhbl.utils.LocationAlarmManager
import org.greenrobot.eventbus.EventBus

/**
 * Copyright © 2025 zhun All rights reserved.
 * Created by ZhaoZhun on 2025/3/13 11:43.
 * @author: ZhaoZhun 1820022519@qq.com
 * @version: V1.0
 */
class VersionUpdateAlarmReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent?) {
        if (intent?.action == "ALARM_ACTION") {
            EventBus.getDefault().post(VersionUpdateEvent())
            Log.d("AlarmReceiver", "定时任务触发：${System.currentTimeMillis()}")
            // 任务执行完后，重新设置下次 1 点的定时任务
            LocationAlarmManager.startUpdateAlarm()
        }
    }
}